<?php

namespace Xrfg\Api\Trading\Account\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;

class ServiceProvider extends IlluminateServiceProvider
{
    public function boot()
    {
        $this->registerRoutes();
        $this->registerValidator();
    }

    public function register()
    {
        $this->mergeConfigFrom(
            __DIR__.'/../../config/error.php',
            'error'
        );
    }

    private function registerRoutes()
    {
        Route::prefix('api/account')
            ->middleware('api')
            ->namespace('Xrfg\\Api\\Trading\\Account\\Controllers')
            ->group(function () {
                $this->loadRoutesFrom(__DIR__.'/../../routes/api.php');
            });
    }

    private function registerValidator()
    {
        Validator::extend('walletAddressValidator', '\Xrfg\Api\Trading\Account\Rules\Validator@walletAddressValidator');
    }
}
